package com.itCar.base.api.wxApi.wxAuth.manager;

import com.itCar.base.api.wxApi.wxAuth.util.Utils;
import com.itCar.base.api.wxApi.wxAuth.util.WxAuthUtil;
import org.junit.jupiter.api.Test;

import javax.rmi.CORBA.Util;

/**
 * @ClassName: TemplateMessageManager
 * @Description: TODO 模板消息
 * @author: liuzg
 * @Date: 2022/9/1 15:17
 * @Week: 星期四
 * @Version: v1.0
 */
public class TemplateMessageManager {

    @Test // 设置行业
    public void setIndustry() {
        String at = WxAuthUtil.getAccessToken();
        String url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=" + at;
        String data = "{\n" +
                "    \"industry_id1\":\"1\",\n" +
                "    \"industry_id2\":\"4\"\n" +
                "}";
        String result = Utils.post(url, data);
        System.out.println(result);
    }

    @Test // 获取我所在的行业
    public void get() {
        String at = WxAuthUtil.getAccessToken();
        String url = "https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token=" + at;
        String result = Utils.get(url);
        System.out.println(result);
    }


    @Test // 发送模板消息
    public void sendTemplateMessage() {
        String at = WxAuthUtil.getAccessToken();
        String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + at;
        // 格式可以参考自定义菜单使用面向对象
        String data = "{\n" +
                "    \"touser\":\"oCagm6KvnAL8F43CwoIa5ty1OyXw\",\n" +
                "    \"template_id\":\"THbp-IuhO7yUz1CNL-yEi1A4-TmPRg9DD7rlOGrMu-s\",\n" +
                "    \"data\":{\n" +
                "        \"first\":{\n" +
                "            \"value\":\"你有新的反馈信息了！\",\n" +
                "            \"color\":\"#173177\"\n" +
                "        },\n" +
                "        \"company\":{\n" +
                "            \"value\":\"城市地理\",\n" +
                "            \"color\":\"#173177\"\n" +
                "        },\n" +
                "        \"time\":{\n" +
                "            \"value\":\"2022-09-01\",\n" +
                "            \"color\":\"#173177\"\n" +
                "        },\n" +
                "        \"result\":{\n" +
                "            \"value\":\"面试通过\",\n" +
                "            \"color\":\"#173177\"\n" +
                "        },\n" +
                "        \"remark\":{\n" +
                "            \"value\":\"请和公司人事联系\",\n" +
                "            \"color\":\"#173177\"\n" +
                "        }\n" +
                "    }\n" +
                "}";
        String result = Utils.post(url, data);
        System.out.println(result);
    }


}
